package com.temp.flyway;

import org.flywaydb.core.Flyway;

public class FlyWayTest {


    public static void main(String[] args) {

        // 数据库连接配置
        String url = "jdbc:mysql://192.168.30.201:28995/atest?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true";
        String user = "root";
        String password = "qp*imsp666";

        // 创建 Flyway 实例
        Flyway flyway = Flyway.configure()
                .cleanDisabled(true)
                .baselineOnMigrate(true)
                .dataSource(url, user, password)
                .validateOnMigrate(false)
                .locations("classpath:db/migration")  // 迁移脚本存放的位置
                .load();
        // 执行数据库迁移
        flyway.migrate();
    }
}
